package com.lwq.ide;

import org.mozilla.javascript.Context;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.Script;
import org.mozilla.javascript.Scriptable;

import com.lwq.cocos.CCNode;
import com.lwq.util.GsonUtil;
import com.lwq.util.JsUtil;

public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		int sw = 3;
		if(sw == 1){
	        JsUtil jsUtil = new JsUtil();  
	        jsUtil.compileString("res/js/one.js");
	        Scriptable scope = jsUtil.getScope();  
	        Function fc = (Function) scope.get("getWidth", scope);   
	        float width = (Float) fc.call(Context.getCurrentContext(), scope, fc, new Object[] { "this is my test" });
	        System.out.println("width="+width);   
		}else if(sw == 2){
			CCNode node = new CCNode("test"); 
			CCNode child = new CCNode("child");
			node.addChild(child);
			String str = GsonUtil.getInstance(GsonUtil.BUILD_TYPE).modelToJson(node);
			if(str != null){
				 System.out.println("str="+str);   
			}
		}else if(sw == 3){
			float obj = Float.valueOf(JsUtil.getInstance().runCmd("0.1").toString());
				 System.out.println("obj="+obj);   
		}
        
	}

}
